package br.com.fpf.pontoapp.model.dao.impl;

import android.content.ContentValues;
import android.database.Cursor;
import br.com.fpf.pontoapp.model.bo.IBeatsPontBO;
import br.com.fpf.pontoapp.model.db.impl.Table;
import br.com.fpf.pontoapp.model.entity.BeatsPoint;

public class BeatsPointDAO extends AbstractDAO<BeatsPoint> implements
		IBeatsPontBO {

	private static final long serialVersionUID = 1L;

	public BeatsPointDAO() {
		super(Table.BEATS_POINT.getName());
	}

	@Override
	protected BeatsPoint cursorToObject(Cursor cursor) {

		BeatsPoint beatsPoint = new BeatsPoint();

		int column = cursor.getColumnIndex(BeatsPoint.ID_COLUMN);
		if (column > 0) {
			beatsPoint.setId(cursor.getLong(column));
		}

		column = cursor.getColumnIndex(BeatsPoint.HOUR_BEAT);
		if (column > 0) {
			beatsPoint.setHourBeat(cursor.getString(column));
		}

		return beatsPoint;
	}

	@Override
	protected ContentValues objectToContentValues(BeatsPoint entity) {

		final ContentValues values = new ContentValues();

		if (entity.getHourBeat() != null) {
			values.put(BeatsPoint.HOUR_BEAT, entity.getHourBeat());
		}

		return values;
	}

}
